package com.guaju.yueshangclothing.viewmodel.login;

import android.content.Intent;
import android.databinding.BaseObservable;
import android.view.View;

import com.guaju.yueshangclothing.activity.FindPasswordActivity;
import com.guaju.yueshangclothing.activity.RegistActivity;
import com.guaju.yueshangclothing.utils.NotifyUtil;
import com.guaju.yueshangclothing.utils.ToastUtil;

/**
 * Created by guaju on 2018/10/12.
 */

public class LoginVM extends BaseObservable{


    public String phoneNum;
    public String password;
    private Intent intent;


    public void login(String phoneNum, String password){
        if (!NotifyUtil.isPhoneNum(phoneNum)){
            ToastUtil.show("手机号格式不正确,请修改");
        }else if (!NotifyUtil.isLetterAndDigit(password)){
            ToastUtil.show("密码错误,请检查");
        }else{
            //服务器校验
        }
    }

    public void login(View v){
       login(phoneNum,password);
    }
    public void toRegist (View v){
        intent = new Intent(v.getContext(), RegistActivity.class);
        v.getContext().startActivity(intent);
    }
    public void toFindPassword(View v){
        intent = new Intent(v.getContext(), FindPasswordActivity.class);
        v.getContext().startActivity(intent);
    }
}
